package com.lankystar.sos.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lankystar.sos.dao.IPharmacyDao;
import com.lankystar.sos.model.Pharmacy;
import com.lankystar.sos.service.IPharmacyInterface;

@Service
@Transactional
public class PharmacyInterface implements IPharmacyInterface{

	@Autowired
	private IPharmacyDao pharmacyDao;
	@Override
	public Map<String, Object> queryPharmacylistMethod(Double longitude,Double latitude) {
		Map<String, Object> maplist = new HashMap<>();
		List<Pharmacy> pharmacys = pharmacyDao.selectPharmacylist(longitude, latitude);
		Object[] ob = new Object[pharmacys.size()];
		int i = 0;
		for (Pharmacy p : pharmacys) {
			Map<String, Object> map = new HashMap<>();
			map.put("PharmacyId", p.getPharmacyId());
			map.put("CreateTime", p.getCreateTime());
			map.put("LastUpdateTime", p.getLastUpdateTime());
			map.put("PharmacyAddress", p.getPharmacyAddress());
			map.put("Latitude", p.getLatitude());
			map.put("Longitude", p.getLongitude());
			map.put("PharmacyName", p.getPharmacyName());
			map.put("PharmacyPhone", p.getPharmacyPhone());
			ob[i] = map;
			i++;
		}
		maplist.put("Pharmacy", ob);
		return maplist;
	}

}
